package pers.sen.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import pers.sen.health.po.OrderSetting;

import java.util.List;

/**
 * @author Jason
 * @version 1.0.0
 * @date 2020/11/9 20:23
 * @Description TODO
 */
public interface OrderSettingMapper extends BaseMapper<OrderSetting> {
    @Select("select  ORDERDATE,NUMBER,RESERVATIONS from t_ordersetting where  orderdate like #{queryString}")
    List<OrderSetting> findSettingDataByYearAndMonth(@Param("queryString") String queryString);

    @Update("update t_ordersetting  set number= #{number}  where  orderdate= #{settingDay}")
    Boolean updateNumberByOrderDate(@Param("number") int number, @Param("settingDay") String settingDay);

    @Select("select count(1) from t_ordersetting where number > RESERVATIONS and orderdate = #{orderdate}")
    int isOrderOk(@Param("orderdate") String orderdate);

    @Update("update t_ordersetting set  RESERVATIONS = RESERVATIONS+1  where orderdate = #{orderdate}")
    void updateReservationByOrderDate(@Param("orderdate") String orderdate);
}
